/** BCMI_Frame Clock Tool
 *
 *  BCMI_Frame Clock Tool
 *  Get system time and MPI time
 *
 *  @author : huicong
 *  @date : 2008-10-28
 *
 */

#include <ctime>

#ifndef _FRAME_CLOCK_H
#define _FRAME_CLOCK_H


namespace bcmi_frame
{

    /** //UNDo
     *
     *
     */
    class FrameClock
    {
    public:

        FrameClock()
        {
            _createdSystemTime = time(NULL);
            _createdMPITime = MPI_Wtime();
        }

        ~FrameClock()
        {
        }

    public:

        /** Return current system time from this class has been created or reCount. */
        INT64 getCurrentSystemTime()
        {
            return time(NULL) - _createdSystemTime;
        }

        /** Return current MPI time from this class has been created or reCount. */
        DOUBLE getCurrentMPITime()
        {
            return MPI_Wtime() - _createdMPITime;
        }

#ifdef DEBUG_FRAME_CLOCK_RECOUNT
        /** Recount system time. */
        VOID recountSystemTime()
        {
            _createdSystemTime = time(NULL);
        }

        /** Recount MPI time. */
        VOID recountMPITime()
        {
            _createdMPITime = MPI_Wtime();
        }
#endif //#ifdef DEBUG_FRAME_CLOCK_RECOUNT

    private:
        INT64 _createdSystemTime;
        DOUBLE _createdMPITime;
    };

};//namespace bcmi_frame

#endif //#ifndef _FRAME_CLOCK_H